﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WordDocumentGenerator.Library;

namespace GPS.ENTITYS
{
    public class CrudModelDHV
    {
        public decimal ID { get; set; }

        [Display(Name = "Mã học viên viên")]
        public string HV_MA { get; set; }

        [Display(Name = "Đơn vị GTVT")]
        [Required(ErrorMessage = "Đơn vị GTVT bắt buộc nhập")]
        public string HV_DVGTVT_MA { get; set; }
        public string HV_HANGDT_MA { get; set; }
        [DisplayFormat(DataFormatString = "{0:0}", ApplyFormatInEditMode = true)]
        public Nullable<decimal> HV_HANGDT_RANK { get; set; }

        public string HV_KH_MA { get; set; }

        [Display(Name = "Họ đệm")]
        [Required(ErrorMessage = "Họ đệm bắt buộc nhập")]
        public string HV_HODEM { get; set; }

        [Display(Name = "Tên")]
        [Required(ErrorMessage = "Tên bắt buộc nhập")]
        public string HV_TEN { get; set; }

        [Display(Name = "Giới tính")]
        [Required(ErrorMessage = "Giới tính bắt buộc nhập")]
        public string HV_GIOITINH { get; set; }

        [Display(Name = "Quốc tịch")]
        [Required(ErrorMessage = "Quốc tịch bắt buộc nhập")]
        public string HV_QUOCTICH_MA { get; set; }

        [Display(Name = "Ngày sinh")]
        [Required(ErrorMessage = "Ngày sinh bắt buộc nhập")]
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public string HV_NGAYSINH { get; set; }
        public string HV_NOITT { get; set; }
        public string HV_NOITT_DVHC_MA { get; set; }
        public string HV_NOITT_DVHC_DVQL { get; set; }
        public string HV_NOICT { get; set; }
        public string HV_NOICT_DVHC_MA { get; set; }
        public string HV_NOICT_DVHC_DVQL { get; set; }
        [Display(Name = "Số CMTND")]
        [Required(ErrorMessage = "Số CMTND bắt buộc nhập")]
        public string HV_SOCMT { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public Nullable<System.DateTime> HV_NGAYCAPCMT { get; set; }
        public string HV_NOICAPCMT { get; set; }
        public string HV_MOTA { get; set; }
        public bool HV_ACTIVE { get; set; }
        public Nullable<System.DateTime> HV_NGAYNHAP { get; set; }
        public string HV_NGUOINHAP { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public Nullable<System.DateTime> HV_NGAYSUA { get; set; }
        public string HV_NGUOISUA { get; set; }
    }

    public class OneCrudModelDHV
    {
        public decimal ID { get; set; }

        [Display(Name = "Mã học viên viên")]
        public string HV_MA { get; set; }

        [Display(Name = "Đơn vị GTVT")]
        [Required(ErrorMessage = "Đơn vị GTVT bắt buộc nhập")]
        public string HV_DVGTVT_MA { get; set; }
        public string HV_HANGDT_MA { get; set; }
        [DisplayFormat(DataFormatString = "{0:0}", ApplyFormatInEditMode = true)]
        public Nullable<decimal> HV_HANGDT_RANK { get; set; }

        public string HV_KH_MA { get; set; }

        [Display(Name = "Họ đệm")]
        [Required(ErrorMessage = "Họ đệm bắt buộc nhập")]
        public string HV_HODEM { get; set; }

        [Display(Name = "Tên")]
        [Required(ErrorMessage = "Tên bắt buộc nhập")]
        public string HV_TEN { get; set; }

        [Display(Name = "Giới tính")]
        [Required(ErrorMessage = "Giới tính bắt buộc nhập")]
        public string HV_GIOITINH { get; set; }

        [Display(Name = "Quốc tịch")]
        [Required(ErrorMessage = "Quốc tịch bắt buộc nhập")]
        public string HV_QUOCTICH_MA { get; set; }

        [Display(Name = "Ngày sinh")]
        [Required(ErrorMessage = "Ngày sinh bắt buộc nhập")]
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public string HV_NGAYSINH { get; set; }
        public string HV_NOITT { get; set; }
        public string HV_NOITT_DVHC_MA { get; set; }
        public string HV_NOITT_DVHC_DVQL { get; set; }
        public string HV_NOICT { get; set; }
        public string HV_NOICT_DVHC_MA { get; set; }
        public string HV_NOICT_DVHC_DVQL { get; set; }
        [Display(Name = "Số CMTND")]
        [Required(ErrorMessage = "Số CMTND bắt buộc nhập")]
        public string HV_SOCMT { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public Nullable<System.DateTime> HV_NGAYCAPCMT { get; set; }
        public string HV_NOICAPCMT { get; set; }
        public string HV_MOTA { get; set; }
        public string HV_HS_HOSO_MA { get; set; }
        public byte[] HV_HS_ANH { get; set; }
        public string HV_HS_DVGTVT_MA_NHANHS { get; set; }
        public string HV_HS_DONVICAPGPLXDACO { get; set; }
        public string HV_HS_SOGPLXDACO { get; set; }
        public string HV_HS_MAHTCAP { get; set; }
        public string HV_HS_HANGGPLXDACO { get; set; }
        public string HV_HS_NGAYCAPGPLXDACO { get; set; }
        public string HV_HS_NOICAPGPLXDACO { get; set; }
        public string HV_HS_TTXL_MA { get; set; }
        public string HV_HS_SOHOSO { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public DateTime? HV_HS_NGAYINGIAYTN { get; set; }
        public DateTime? HV_HS_NGAYHENTRA { get; set; }
    }

    public class EXPORTWORD_HOCVIEN
    {
        public static byte[] EXPORT_HOCVIEN(string templateFileName, object objSource, string docType)
        {
            DocumentGenerationInfo generationInfo = GetDocumentGenerationInfo(docType, "1.0", objSource, templateFileName, false);
            COMMON.ExportCore<OneCrudModelDHV> docGenerator = new COMMON.ExportCore<OneCrudModelDHV>(generationInfo);
            return docGenerator.GenerateDocument();
        }
        /// <summary>
        /// Gets the document generation info.
        /// </summary>
        /// <param name="docType">Type of the doc.</param>
        /// <param name="docVersion">The doc version.</param>
        /// <param name="dataContext">The data context.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="useDataBoundControls">if set to <c>true</c> [use data bound controls].</param>
        /// <returns></returns>
        private static DocumentGenerationInfo GetDocumentGenerationInfo(string docType, string docVersion, object dataContext, string fileName, bool useDataBoundControls)
        {
            DocumentGenerationInfo generationInfo = new DocumentGenerationInfo();
            generationInfo.Metadata = new DocumentMetadata
            {
                DocumentType = docType,
                DocumentVersion = docVersion
            };
            generationInfo.DataContext = dataContext;
            generationInfo.TemplateData = File.ReadAllBytes(fileName);
            generationInfo.IsDataBoundControls = useDataBoundControls;
            return generationInfo;
        }

    }

    #region Xuất word hợp đồng
    public class ExportDHV_hopDong
    {
        public string SOHOPDONG { get; set; }
        public string DATETIME_NOW { get; set; }
        public string DVGTVT_TEN { get; set; }
        public string DVGTVT_SOGP { get; set; }
        public string DVGTVT_NGAYGP { get; set; }
        public string DVGTVT_LANHDAO { get; set; }
        public string DVGTVT_ADD { get; set; }
        public string DVGTVT_TEL { get; set; }
        public string DVGTVT_FAX { get; set; }
        public string HOTEN { get; set; }
        public string HV_NGAYSINH { get; set; }
        public string HV_NOICT { get; set; }
        public string HV_DANGKY { get; set; }
        public string DTMONHOC_MA { get; set; }
        public string DTMONHOC_TEN { get; set; }
        public string DTMONHOC_TONGGIO { get; set; }
        public string DTMONHOC_GIOLT { get; set; }
        public string DTMONHOC_GIOTHHINH { get; set; }
        public string DTMONHOC_GIOTHDUONG { get; set; }
        public string DTMONHOC_KIEMTRA { get; set; }
        public string KH_TEN { get; set; }
        public List<ExportDHV_hopDong> LISTHopDong { get; set; }
    }
    public class EXPORTWORD_DHV_HopDong
    {
        public static byte[] EXPORT_HOCVIENHD(string templateFileName, object objSource, string docType)
        {
            DocumentGenerationInfo generationInfo = GetDocumentGenerationInfo(docType, "1.0", objSource, templateFileName, false);
            COMMON.ExportCore<ExportDHV_hopDong> docGenerator = new COMMON.ExportCore<ExportDHV_hopDong>(generationInfo);
            return docGenerator.GenerateDocument();
        }
        /// <summary>
        /// Gets the document generation info.
        /// </summary>
        /// <param name="docType">Type of the doc.</param>
        /// <param name="docVersion">The doc version.</param>
        /// <param name="dataContext">The data context.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="useDataBoundControls">if set to <c>true</c> [use data bound controls].</param>
        /// <returns></returns>
        private static DocumentGenerationInfo GetDocumentGenerationInfo(string docType, string docVersion, object dataContext, string fileName, bool useDataBoundControls)
        {
            DocumentGenerationInfo generationInfo = new DocumentGenerationInfo();
            generationInfo.Metadata = new DocumentMetadata
            {
                DocumentType = docType,
                DocumentVersion = docVersion
            };
            generationInfo.DataContext = dataContext;
            generationInfo.TemplateData = File.ReadAllBytes(fileName);
            generationInfo.IsDataBoundControls = useDataBoundControls;
            return generationInfo;
        }

    }

    #endregion


    #region Xuất word thanh lý hợp đồng
    public class ExportDHV_TLhopDong
    {
        public string SOHOPDONG { get; set; }
        public string KH_TEN { get; set; }
        public string DATETIME_NOW { get; set; }
        public string DVGTVT_TEN { get; set; }
        public string DVGTVT_SOGP { get; set; }
        public DateTime? DVGTVT_NGAYGP { get; set; }
        public string DVGTVT_LANHDAO { get; set; }
        public string DVGTVT_ADD { get; set; }
        public string DVGTVT_TEL { get; set; }
        public string DVGTVT_FAX { get; set; }
        public string HOTEN { get; set; }
        public string HV_NGAYSINH { get; set; }
        public string HV_NOICT { get; set; }
        public string HV_DANGKY { get; set; }
    }

    public class EXPORTWORD_DHV_TLHopDong
    {
        public static byte[] EXPORT_HOCVIENTLHD(string templateFileName, object objSource, string docType)
        {
            DocumentGenerationInfo generationInfo = GetDocumentGenerationInfo(docType, "1.0", objSource, templateFileName, false);
            COMMON.ExportCore<ExportDHV_TLhopDong> docGenerator = new COMMON.ExportCore<ExportDHV_TLhopDong>(generationInfo);
            return docGenerator.GenerateDocument();
        }
        /// <summary>
        /// Gets the document generation info.
        /// </summary>
        /// <param name="docType">Type of the doc.</param>
        /// <param name="docVersion">The doc version.</param>
        /// <param name="dataContext">The data context.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="useDataBoundControls">if set to <c>true</c> [use data bound controls].</param>
        /// <returns></returns>
        private static DocumentGenerationInfo GetDocumentGenerationInfo(string docType, string docVersion, object dataContext, string fileName, bool useDataBoundControls)
        {
            DocumentGenerationInfo generationInfo = new DocumentGenerationInfo();
            generationInfo.Metadata = new DocumentMetadata
            {
                DocumentType = docType,
                DocumentVersion = docVersion
            };
            generationInfo.DataContext = dataContext;
            generationInfo.TemplateData = File.ReadAllBytes(fileName);
            generationInfo.IsDataBoundControls = useDataBoundControls;
            return generationInfo;
        }

    }

    #endregion

    #region Xuất Word báo cáo 1
    public class ExportDHV_BC1
    {
        public string DATETIME_NOW { get; set; }
        public string DVGTVT_TEN { get; set; }
        public string KH_HANGGPLX_MA { get; set; }
        public string KH_TEN { get; set; }
        public string KH_NGAYKG { get; set; }
        public string KH_NGAYBG { get; set; }
        public string KH_THOIGIANDT { get; set; }
        public string STT { get; set; }
        public string HV_HOTEN { get; set; }
        public string HV_NGAYSINH { get; set; }
        public string HV_SOCMT { get; set; }
        public string HV_NOICT { get; set; }
        public string HV_HS_COGIAYCNSK { get; set; }
        public string HV_HS_HANGGPLXDACO { get; set; }
        public string HV_HS_SONAMLX { get; set; }
        public string HV_HS_SOKMLXANTOAN { get; set; }
        public string HV_HS_MOTA { get; set; }
        
        public List<ExportDHV_BC1> LIST_HS { get; set; }
        
    }

    public class EXPORTWORD_DHV_BC1
    {
        public static byte[] EXPORT_HOCVIENBC1(string templateFileName, object objSource, string docType)
        {
            DocumentGenerationInfo generationInfo = GetDocumentGenerationInfo(docType, "1.0", objSource, templateFileName, false);
            COMMON.ExportCore<ExportDHV_BC1> docGenerator = new COMMON.ExportCore<ExportDHV_BC1>(generationInfo);
            return docGenerator.GenerateDocument();
        }
        /// <summary>
        /// Gets the document generation info.
        /// </summary>
        /// <param name="docType">Type of the doc.</param>
        /// <param name="docVersion">The doc version.</param>
        /// <param name="dataContext">The data context.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="useDataBoundControls">if set to <c>true</c> [use data bound controls].</param>
        /// <returns></returns>
        private static DocumentGenerationInfo GetDocumentGenerationInfo(string docType, string docVersion, object dataContext, string fileName, bool useDataBoundControls)
        {
            DocumentGenerationInfo generationInfo = new DocumentGenerationInfo();
            generationInfo.Metadata = new DocumentMetadata
            {
                DocumentType = docType,
                DocumentVersion = docVersion
            };
            generationInfo.DataContext = dataContext;
            generationInfo.TemplateData = File.ReadAllBytes(fileName);
            generationInfo.IsDataBoundControls = useDataBoundControls;
            return generationInfo;
        }

    }
    #endregion

}
